<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title></title>
    <link rel="shortcut icon" type="image/x-icon" href="/favicon.ico"/>
    <link rel="stylesheet" href="/Y-Admin/layui/css/layui.css">
    <link rel="stylesheet" href="/Y-Admin/css/common.css">
    <link rel="stylesheet" href="/Y-Admin/layui/extend/dtree.css">
    <link rel="stylesheet" href="/Y-Admin/layui/extend/font/dtreefont.css">
    <link rel="stylesheet" href="/Y-Admin/layui/extend/formSelects-v4.css">

    <style>
        .content {
            padding: 15px;
        }

        i {
            margin-right: 10px;
        }

        .item {
            margin-bottom: 15px;
            box-shadow: 1px 1px 5px 3px #eeeeee;
        }

        .layui-card-body {
            border-bottom: 1px solid #dcdada;
        }

        .exe-1 {
            margin-right: 20px;
            display: inline-block;
        }

        .w-e-text-container {
            height: 300px !important; /*!important是重点，因为原div是行内样式设置的高度300px*/
        }

        blockquote {
            display: block;
            border-left: 8px solid #d0e5f2;
            padding: 5px 10px;
            margin: 10px 0;
            line-height: 1.4;
            font-size: 100%;
            background-color: #f1f1f1;
        }

        .layui-bg-gray {
            padding: 2px 8px;
            margin-right: 20px;
        }
    </style>
</head>
<body>
<div class="yadmin-body animated fadeIn">
    <div class="layui-col-md12" style="margin-bottom: 15px">
        <span class="layui-badge layui-bg-green" style="margin-bottom: 5px">问卷标题：${questionnaire.title}</span>
        <span class="layui-badge layui-bg-green"
              style="margin-bottom: 5px">发布时间：<fmt:formatDate value="${questionnaire.creatTime}" pattern="yyyy-MM-dd HH:mm:ss"/></span>
        <span class="layui-badge" style="margin-bottom: 5px">参与人数：${questionnaire.partakeCount}</span>
    </div>
    <div class="layui-col-md12">
        <div class="layui-col-md12">
            <c:forEach items="${questionList}" var="item" varStatus="xh">
                <div class="layui-card item">
                    <div class="layui-card-header" style="position: relative">
                        <span class="layui-badge layui-bg-gray"># ${xh.count}</span>
                    </div>
                    <div class="layui-card-body" style="border-bottom: 1px solid #eeeeee">
                        <div style="margin-bottom: 5px">
                            <strong>
                                <label style="color: red; margin-right: 5px">*</label>题干
                            </strong>
                        </div>
                            ${item.questionStem}
                    </div>
                    <div class="layui-card-body" style="min-height: 30px;">
                        <div class="exe-1">
                        <span class="layui-badge layui-bg-black" style="padding: 2px 8px">
                            A、${item.optionA}
                        </span>
                        </div>
                        <div class="exe-1">
                        <span class="layui-badge layui-bg-black" style="padding: 2px 8px">
                            B、${item.optionB}
                        </span>
                        </div>
                        <div class="exe-1">
                        <span class="layui-badge layui-bg-black" style="padding: 2px 8px">
                            C、${item.optionC}
                        </span>
                        </div>
                        <div class="exe-1">
                        <span class="layui-badge layui-bg-black" style="padding: 2px 8px">
                            D、${item.optionD}
                        </span>
                        </div>
                    </div>
                </div>
            </c:forEach>
        </div>
    </div>

    <div class="layui-col-md12">
        <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px; color: #009E94">
            <legend>参与人员列表</legend>
        </fieldset>
    </div>

    <div class="layui-col-md12">
        <div class="layui-form" lay-filter="name">
            <div class="layui-form-item">
                <div class="layui-input-inline">
                    <input type="text" name="name"
                           placeholder="请输入昵称" autocomplete="off" class="layui-input">
                </div>
                <div class="layui-input-inline">
                    <input type="text" name="cellphone"
                           placeholder="请输入联系电话" autocomplete="off" class="layui-input">
                </div>
                <div class="layui-input-inline">
                    <button class="layui-btn layui-btn" lay-submit lay-filter="search">
                        <i class="layui-icon">&#xe615;</i>搜索
                    </button>
                </div>
            </div>
        </div>
    </div>

    <div class="layui-col-md12">
        <table class="layui-hide" id="dataTable" lay-filter="dataTable"></table>
    </div>

</div>

<script type="text/html" id="column-toolbar">

    <button type="button" class="layui-btn layui-btn-xs" lay-event="item">
        <i class="layui-icon layui-icon-screen-full" title="详情"></i>
        详情
    </button>

    <button type="button" class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">
        <i class="layui-icon layui-icon-delete" title="删除"></i>
        删除
    </button>

</script>

<script src="/js/jquery-3.3.1.min.js" charset="utf-8"></script>
<script src="/js/ajax.js" charset="utf-8"></script>
<script src="/Y-Admin/layui/layui.js"></script>
<script src="/Y-Admin/js/common.js"></script>
<script type="text/javascript" src="/wangEditor/release/wangEditor.js"></script>

<script>
    layui.config({
        base: '/Y-Admin/layui/extend/'
    }).use(['table', 'element', 'form'], function () {
        var table = layui.table;
        var form = layui.form;

        form.render('radio');

        table.render({
            elem: '#dataTable'
            , url: '/sys/userQuestionnaire/data'
            , toolbar: '#toolbarDemo' //开启头部工具栏，并为其绑定左侧模板
            , title: '数据表'
            , where: {
                questionnaireId: ${questionnaire.id}
            }
            , cols: [
                [
                    {field: 'id', title: 'ID', width: 110, fixed: 'left', sort: true},
                    {
                        field: 'name', title: '用户昵称', templet: function (data) {
                            return data.user.name;
                        }
                    },
                    {
                        field: 'cellphone', title: '联系电话', templet: function (data) {
                            return data.user.cellphone;
                        }
                    },
                    {fixed: 'right', title: '操作', toolbar: '#column-toolbar', width: 170}
                ]
            ]
            , page: true
        });

        // 搜索
        form.on('submit(search)', function (data) {
            table.reload('dataTable', {
                where: data.field
            }); //只重载数据
        });

        //监听行工具事件
        table.on('tool(dataTable)', function (obj) {
            var data = obj.data;
            if (obj.event == 'del') {
                layer.confirm('真的删除行么？', function (index) {
                    Ax.rest("/sys/userQuestionnaire/delete", data.id, function (data) {
                        obj.del();
                        layer.close(index);
                        layer.msg("删除成功");
                    })
                });
            } else if (obj.event === 'item') {
                location.href = "/sys/userQuestionnaire/result.html?id=" + data.id;
            }
        });

    });
</script>

</body>
</html>